package com.baoyouqun.domain.VO;

import com.baoyouqun.base.utils.ConvertUtils;
import com.baoyouqun.entity.WechatPushRecord;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class WechatPushVO {
    private String id;
    private String title;
    private String content;
    private String filterConditions;
    private LocalDateTime pushTime;
    private Integer status;
    private String statusName;
    private Integer userCount;
    private LocalDateTime createTime;

    public static WechatPushVO fromEntity(WechatPushRecord record) {
        WechatPushVO vo = ConvertUtils.copyBean(record, WechatPushVO.class);
        // 状态名称映射
        if (vo.getStatus() != null) {
            switch (vo.getStatus()) {
                case 0:
                    vo.setStatusName("待推送");
                    break;
                case 1:
                    vo.setStatusName("已推送");
                    break;
                case 2:
                    vo.setStatusName("失败");
                    break;
                default:
                    vo.setStatusName("未知");
            }
        }
        return vo;
    }
}